﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using ProfessorLib.Basic;
using ProfessorLib.Regra;
using ProfessorLib.Repositorio;

namespace ProfessoresService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ServiceProfessor : System.Web.Services.WebService
    {

        RegProfessor regras = new RegProfessor();

        [WebMethod]
        public void inserir(Professor obj)
        {
            try
            {
                regras.campoVazio(obj);
                regras.campoExistente(obj);
                RepProfessor.getInstancia().inserir(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        [WebMethod]
        public List<Professor> listar()
        {
            
            try
            {
                return RepProfessor.getInstancia().listar();
            }
            catch (Exception ex)
            {
                throw ex;
            }
             
        }

        [WebMethod]
        public void alterar(Professor obj)
        {
            try
            {
                regras.campoVazio(obj);
                regras.campoExistenteAlterar(obj);

                RepProfessor.getInstancia().alterar(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}